/**
 * 子元素变化监听器
 * @param {*} element 要监听的dom元素 
 * @param {*} callback 监听到的回调
 */
const addMutationObserver = (element, callback) => {
  if(typeof element === 'undefined') {
    return
  }
  const observer = new MutationObserver(callback)
  observer.observe(element, {
    childList: true,
    attributes: true,
    subtree: true
  })
  return observer
}

export default addMutationObserver